package com.ws.ssmzongjie3.config;

import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import javax.servlet.Filter;

public class ServletConfig extends AbstractAnnotationConfigDispatcherServletInitializer{
    protected Class<?>[] getRootConfigClasses(){
        return new Class[]{SpringConfig.class};
    }
    protected Class<?>[] getServletConfigClasses(){
        return new Class[]{SpringMvcConfig.class};
    }
    protected String[]getServletMappings(){
        return new String[]{"/"};
    }

    @Override
    protected Filter[] getServletFilters() { //中文过滤器
        CharacterEncodingFilter filter = new CharacterEncodingFilter();
        filter.setEncoding("UTF-8");
        filter.setForceEncoding(true);
        return new Filter[]{filter};
    }
}